# Copyright 2023 Chengfang Financial Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:yacl.bzl", "yacl_cc_library", "yacl_cc_test")

package(default_visibility = ["//visibility:public"])

yacl_cc_library(
    name = "kdf",
    srcs = ["kdf.cc"],
    hdrs = ["kdf.h"],
    deps = ["//yacl/crypto/hash:hash_utils"],
)

yacl_cc_test(
    name = "kdf_test",
    srcs = ["kdf_test.cc"],
    deps = [":kdf"],
)

yacl_cc_library(
    name = "hash",
    srcs = ["hash.cc"],
    hdrs = ["hash.h"],
    deps = [
        ":kdf",
        "//yacl/crypto/ecc:spi",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
    ],
)

yacl_cc_test(
    name = "hash_test",
    srcs = ["hash_test.cc"],
    deps = [
        ":hash",
        "//yacl/crypto/ecc",
        "//yacl/math/mpint",
    ],
)

yacl_cc_library(
    name = "keys",
    srcs = ["keys.cc"],
    hdrs = ["keys.h"],
    deps = [
        ":hash",
        "//yacl/crypto/ecc:spi",
        "//yacl/math/mpint",
    ],
)

yacl_cc_test(
    name = "keys_test",
    srcs = ["keys_test.cc"],
    deps = [
        ":keys",
        "//yacl/crypto/ecc",
        "//yacl/crypto/ecc:spi",
        "//yacl/math/mpint",
    ],
)

yacl_cc_library(
    name = "capsule",
    srcs = ["capsule.cc"],
    hdrs = [
        "capsule.h",
        "keys.h",
    ],
    deps = [
        ":hash",
        ":kdf",
        "//yacl/crypto/ecc:spi",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
    ],
)

yacl_cc_test(
    name = "capsule_test",
    srcs = ["capsule_test.cc"],
    deps = [
        ":capsule",
        ":keys",
        "//yacl/base:exception",
        "//yacl/crypto/ecc",
        "//yacl/crypto/ecc:spi",
        "//yacl/math/mpint",
        "//yacl/utils:scope_guard",
        "@abseil-cpp//absl/strings",
    ],
)

yacl_cc_library(
    name = "tpre",
    srcs = ["tpre.cc"],
    hdrs = [
        "capsule.h",
        "keys.h",
        "tpre.h",
    ],
    deps = [
        ":capsule",
        ":keys",
        "//yacl/crypto/aead:sm4_mte",
        "//yacl/crypto/ecc:spi",
    ],
)

yacl_cc_test(
    name = "tpre_test",
    srcs = ["tpre_test.cc"],
    deps = [
        ":capsule",
        ":keys",
        ":tpre",
        "//yacl/crypto/ecc",
        "//yacl/crypto/ecc:spi",
        "@abseil-cpp//absl/strings",
    ],
)
